use "C:\CGD\Climate\FORMA\AData SE Asia\WB Paper\Reg Data"

drop lpd
gen lpd=log(pd+.001)

drop if year<2006

drop if island=="Bali" | island=="Java" | province=="Nusa Tenggara Barat" | province=="Nusa Tenggara Timur"

sort admin mdate

tsset admin mdate

*** Table 1 ***

* [-t] denotes lagged t months

* lpd: Log Forest Clearing Index
* lr1: Log Rainfall [-1]
* lpp: Log Palm Oil Futures Price
* lpl9: Log Sawlog Price [-9]
* lppa15: Log Global Palm Oil Production [-15]
* lppl12: Log Global Sawlog Production [-12]
* rlintrate23: Real Interest Rate [-23]
* lx91011: Log Exchange Rate [Mean -9,-10,-11]
* lcelldns12: Log Mobile Phone Coverage [-12]

xtreg lpd lr1 lpp lpl9 lppa15 lppl12 rlintrate23 lx91011 lcelldns12, fe
estimates store fixed
outreg using "C:\CGD\Climate\FORMA\regres1",replace
xtreg lpd lr1 lpp lpl9 lppa15 lppl12 rlintrate23 lx91011 lcelldns12, re
estimates store random 
outreg using "C:\CGD\Climate\FORMA\regres1",append
hausman fixed random

xtreg lpd lr1 lpp lpl9 lppa15 lppl12 rlintrate23 lx91011 lcelldns12 if island=="Sumatra", re
outreg using "C:\CGD\Climate\FORMA\regres1",append
xtreg lpd lr1 lpp lpl9 lppa15 lppl12 rlintrate23 lx91011 lcelldns12 if island=="Kalimantan", re
outreg using "C:\CGD\Climate\FORMA\regres1",append
xtreg lpd lr1 lpp lpl9 lppa15 lppl12 rlintrate23 lx91011 lcelldns12 if island=="Sulawesi", re
outreg using "C:\CGD\Climate\FORMA\regres1",append
xtreg lpd lr1 lpp lpl9 lppa15 lppl12 rlintrate23 lx91011 lcelldns12 if island=="Maluku", re
outreg using "C:\CGD\Climate\FORMA\regres1",append
xtreg lpd lr1 lpp lpl9 lppa15 lppl12 rlintrate23 lx91011 lcelldns12 if island=="Irian Jaya", re
outreg using "C:\CGD\Climate\FORMA\regres1",append

clear

*** Table 2 ***

*** Regression (1) using Stata code below; others using tailored spatial econometric estimator (for code contact Dan Hammer: dan.s.hammer@gmail.com)

* [-t] denotes lagged t months

* lpd: Log Forest Clearing Index
* lr1: Log Rainfall [-1]
* lpp: Log Palm Oil Futures Price
* lpl9: Log Sawlog Price [-9]
* lppa15: Log Global Palm Oil Production [-15]
* lppl12: Log Global Sawlog Production [-12]
* rlintrate23: Real Interest Rate [-23]
* lx91011: Log Exchange Rate [Mean -9,-10,-11]
* lcelldns12: Log Mobile Phone Coverage [-12]
* lfor2000: Log Uncleared Forest (2000)
* lslope: Log Mean Slope
* lsdslope: Log St. Dev. Slope
* loppcost: Log Land Opportunity Cost
* protpct: Protected Area Percent
* tmbrpct: Timber Plantation Area %
* logpct: Logging Concession Area %
* kebpct: Palm Oil Plantation %
* lmpdens: Log Population Density
* poverty_rate: Poverty Rate (2000)
* laccess: Log Access Time to Nearest City (50,000+ Population)
* lsdaccess: Log St. Dev. Access Time to Nearest City (50,000+ Population)


use "C:\CGD\Climate\FORMA\AData SE Asia\WB Paper\Reg Data"

drop lpd
gen lpd=log(pd+.001)

gen grppc=igrp/ipop
by admin: egen mgrppc=mean(grppc)
gen lmgrppc=log(mgrppc)
gen popdens=ipop/area
by admin: egen mpdens=mean(popdens)
gen lmpdens=log(mpdens)

drop if year<2006

drop if island=="Bali" | island=="Java" | province=="Nusa Tenggara Barat" | province=="Nusa Tenggara Timur"

sort admin mdate
tsset admin mdate

xtreg lpd mo lr1 lpp lpl9 lppa15 lppl12 rlintrate23 lx91011 lcelldns12 lfor2000 lslope lsdslope loppcost protpct tmbrpct logpct kebpct lmpdens poverty_rate laccess lsdaccess , re
outreg using "C:\CGD\Climate\FORMA\regres3",replace

